package Demo;

public class Demo01 {
    public static void main(String[] args) {
//        Thread t = new Thread( () -> {
//            System.out.println("hello thread");
//        });
//        System.out.println(t.getState());
        Thread mainThread = Thread.currentThread();
        mainThread.setName("老板");

        Thread t = new Thread( () -> {
            while (!Thread.currentThread().isInterrupted()) {
                System.out.println(Thread.currentThread().getName() + ": 别管我,真忙着呢");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    break;
                }
            }
            System.out.println("啊,差点坏了大事");
        },"李四");
        System.out.println(Thread.currentThread().getName() + ": 让李四转账");
        t.start();
        try {
            Thread.sleep(10*1000);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        System.out.println(Thread.currentThread().getName() + ": 那人是骗子,快停止转账!");
        t.interrupt();

    }
}
